package routes

import (
	"go_middle_template/internal/controller"
	"go_middle_template/internal/middleware"
	"go_middle_template/internal/repository"
	"go_middle_template/internal/service"

	"github.com/gin-gonic/gin"
)

func SetupRouter() *gin.Engine {
	r := gin.Default()
	
	// 初始化依赖
	userRepo := repository.NewUserRepository() // 需要实现
	userService := service.NewUserService(userRepo)
	userCtrl := controller.NewUserController(userService)
	
	// 全局中间件
	r.Use(middleware.Logger(), middleware.Recovery())
	
	api := r.Group("/api")
	{
		user := api.Group("/users")
		{
			user.GET("/", userCtrl.GetUsers)
			user.POST("/", userCtrl.CreateUser)
			user.GET("/:id", userCtrl.GetUserByID)
		}
	}
	
	return r
}